<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<link href="${ctx}/css/main/base.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/css/main/main.css" rel="stylesheet" type="text/css"/>

<body class="m_6" style="over">
<form method="post" name="myform">
<div id="main">
	<div class="zdsz" id="select1">
		<div class="zd_gut">
		<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="45%" height="25" align="center" class="w1 bg4 center"><strong>可选</strong></td>
      <td height="25" align="center" bgcolor="#EBF4FC">&nbsp;</td>
      <td width="45%" height="25" align="center" class="w1 bg4 center"><strong>已选</strong></td>
    </tr>
    <tr>
      <td width="45%" align="center" bgcolor="#E3F1FD">
		<select style="width:100%; height:200px" multiple name="list1" size="12" ondblclick="moveOption(document.myform.list1, document.myform.list2)">
	   				<s:iterator value="departments" status="depart">
						<option value="${deptId}">${deptNames}</option>
					</s:iterator>
	  </select></td>
      <td width="12%" align="center" bgcolor="#EBF4FC">
		<input type="button" value="全选" onClick="moveAllOption(document.myform.list1, document.myform.list2)"><br><br>
	  <input type="button" value="全清" onClick="moveAllOption(document.myform.list2, document.myform.list1)">	  </td>
      <td width="45%" align="center" bgcolor="#E3F1FD">
		<select style="width:100%; height:200px" multiple name="list2" size="12" ondblclick="moveOption(document.myform.list2, document.myform.list1)">
	  </select></td>
    </tr>
  </table>
  <table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <input type="hidden" name="usersId" value=""/>
      <input type="hidden" name="usersName" value=""/>
      <td height="50" align="center"><button class="btn" onclick="checkDepart();">确定</button></td>
      <td height="50" align="center"><button class="btn" onclick="javascript:window.close();">取消</button></td>
    </tr>
  </table>
		<div class="bihe"></div>
		</div>
	</div>
</div>
</form>
</body>
</html>
<script type="text/javascript" src="${ctx}/scripts/jquery-1.2.3.pack.js"></script>
<script language="JavaScript">

function moveOption(e1, e2){
	try{
		for(var i=0;i<e1.options.length;i++){
			if(e1.options[i].selected){
				var e = e1.options[i];
				e2.options.add(new Option(e.text, e.value));
				e1.remove(i);
				i=i-1
			}
		}
	}
	catch(e){}
}

function moveAllOption(e1, e2){
	try{
		for(var i=0;i<e1.options.length;i++){
				var e = e1.options[i];
				e2.options.add(new Option(e.text, e.value));
				e1.remove(i);
				i=i-1
		}
	}
	catch(e){}

}

function checkDepart(){

var id=document.getElementById('list2');
	   // var values='';
	    var array=new Array();	
	    for(var i=0;i<id.length;i++)
	    { 
	       array[i]=new Array();
	       array[i][0]=id[i].text;
	       array[i][1]=id[i].value;
	    }
	    window.returnValue=array;
	    window.close();
	    
}

</script>